<?php

namespace App\Model;

class Permission extends Model
{
    protected ?string $table = 'permissions';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = ['id', 'pid', 'name', 'description', 'controller', 'action', 'http_method', 'created_at', 'updated_at', 'deleted_at'];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = ['id' => 'integer', 'pid' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function getHttpMethodAttribute($value)
    {
        return strtoupper($value);
    }

    public function setControllerAttribute($val)
    {
        $this->attributes['controller'] = ucfirst($val);
    }
}